import 'package:bruno/bruno.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:sph_driver/AppConfig/LocalStorage.dart';

import '../../AppConfig/Config.dart';
import '../../AppConfig/RouteAct.dart';
import '../../http/NoLoadingGetApi.dart';
import 'FeedbackProgressDetails.dart';

class FeedbackProgress extends StatefulWidget {
  const FeedbackProgress({super.key});

  @override
  State<FeedbackProgress> createState() => _FeedbackProgressState();
}

class _FeedbackProgressState extends State<FeedbackProgress> {
  List titleList=["信息太多","次数太多"];
  List timeList =["2023-05-23 10:25","2023-05-23 10:25"];
  List dataList=[];
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    getFeedbackList();
  }
    void getFeedbackList()async{
    String? driverId=await UserIdManager.getUserID();
      NoLoadinggetApiManager.getData(
        context,
        "api/system/system/feedback/page",
        {'current':1,"size":20,"userType":"DRIVER","userId":driverId},
            (responseData)  {
          setState(() {
            dataList=responseData['data']['records'];
          });

        },
      );
    }

  @override
  Widget build(BuildContext context) {
    final screenSize = MediaQuery.of(context).size;

    return Scaffold(
      backgroundColor: MyColors.backgreyColor,
      appBar: AppBar(
        leading: IconButton(icon: Icon(Icons.arrow_back_ios,color: Colors.black,),onPressed: (){Navigator.pop(context);},),
        backgroundColor: Colors.white,
        centerTitle: true,
        title: Text("意见反馈进度",style: TextStyle(color: Colors.black,fontWeight: FontWeight.w300,fontSize: 16.sp),),
      ),
      body:ListView.builder(

        itemCount: dataList.length,
        itemBuilder: (BuildContext context, int index) {
          return  GestureDetector(
            child: Container(
              margin: EdgeInsets.only(left: 10.w,right: 10.w,top: 10.h),
              padding: EdgeInsets.only(left: 10.w,right: 10.w,top: 10.h,bottom: 10.h),
              decoration: BoxDecoration(
                  color: Colors.white,
                  borderRadius: BorderRadius.all(Radius.circular(10))),

              child: Column(
                children: [

                  Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [

                      BrnTagCustom(
                        tagText:dataList[index]["status"]==1? '已处理':"等待处理",
                        backgroundColor: MyColors.themeColor,
                        textPadding:EdgeInsets.only(left: 4.w,right: 4.w,top: 2.h,bottom: 2.h),
                        fontSize: 11.sp,
                          tagBorderRadius:BorderRadius.all(Radius.circular(5)),
                      ),
                      Text(dataList[index]['createTime'],style: TextStyle(color: MyColors.authTipColor,fontSize: 13.sp),),

                    ],
                  ),
                  SizedBox(height: 4.h,),
                  Container(
                      constraints: BoxConstraints(
                        maxWidth:screenSize.width-40.w, // 限制文本最大宽度
                      ), // Con
                    child:
                      Text(dataList[index]['firstStageDesc']!=null?dataList[index]['firstStageDesc']:"",style: TextStyle(color: Colors.black,fontSize: 14.sp ),)
                  ),
                  Row(
                    children: [

                      Text(dataList[index]['feedContent'],style: TextStyle(color: Colors.black,fontSize: 13.sp ),)
                    ],
                  ),

                ],
              ),
            ),
            onTap: (){
              Navigator.push( context, FadeRoute(page:FeedbackProgressDetails(dataMap: dataList[index],)));
            },
          );


        },
      ),
    );
  }
}
